
import org.apache.commons.beanutils.PropertyUtils;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.util.List;

@Service
public class FmsMaterialUnitServiceImpl implements FmsMaterialUnitService  {

    @Resource
    private FmsMaterialUnitMapper fmsMaterialUnitMapper;

    /**
     * 获取 FmsMaterialUnit 分页列表
     */
    @Transactional
    public IPage getFmsMaterialUnitPagination( PaginationVo paginationVo, FmsMaterialUnitQuery fmsMaterialUnitQuery ) throws Exception {

        IPage page = new Page( paginationVo.getPageIndex(), paginationVo.getPageSize() );
        LambdaQueryWrapper<FmsMaterialUnitEntity> lqs = new LambdaQueryWrapper();
        fmsMaterialUnitMapper.selectPage(page, lqs);

        List<FmsMaterialUnitEntity> record = page.getRecords();
        if( !ObjectUtil.isNotEmptyList(record)){
            return page;
        }
        return null;
    }


    /**
     * 获取 FmsMaterialUnit 所有数据
     *
    */
    @Transactional
    public List<FmsMaterialUnitEntity> getFmsMaterialUnitAllList( FmsMaterialUnitQuery fmsMaterialUnitQuery ) throws Exception {

        LambdaQueryWrapper<FmsMaterialUnitEntity> lqs = new LambdaQueryWrapper();
        List<FmsMaterialUnitEntity> list = fmsMaterialUnitMapper.selectList(lqs);
        return list;
    }


    /**
     * 获取 FmsMaterialUnit 详情
    */
    @Transactional
    public FmsMaterialUnitEntity getFmsMaterialUnitDetail( Long id) throws Exception {

        FmsMaterialUnitEntity fmsMaterialUnit = fmsMaterialUnitMapper.selectById(id);
        return fmsMaterialUnit;
    }


    /**
     * 新增 FmsMaterialUnit
     * */
    @Transactional
    public void addFmsMaterialUnit(FmsMaterialUnitVo fmsMaterialUnitVo) throws Exception {

        FmsMaterialUnitEntity fmsMaterialUnit = new FmsMaterialUnitEntity();
        ReflectionCopy.copyProperties( fmsMaterialUnit, fmsMaterialUnitVo );
        fmsMaterialUnitMapper.insert(fmsMaterialUnit);
        return;
    }


    /**
     * 更新 FmsMaterialUnit
     * */
    @Transactional
    public void updateFmsMaterialUnit( FmsMaterialUnitVo fmsMaterialUnitVo) throws Exception {

        if( fmsMaterialUnitVo.getId() == null ){
            throw GlobalException.gen(10021, "id不存在");
        }
        FmsMaterialUnitEntity fmsMaterialUnit = new FmsMaterialUnitEntity();
        ReflectionCopy.copyProperties( fmsMaterialUnit, fmsMaterialUnitVo );
        fmsMaterialUnitMapper.updateById(fmsMaterialUnit);
        return;
    }

    /**
     * 删除 FmsMaterialUnit
     * */
    @Transactional
    public void batchRemoveFmsMaterialUnit( List<Long> ids ) throws Exception {


        if( !ObjectUtil.isNotEmptyList(ids) ){
            throw GlobalException.gen(10011, "要删除的id不存在");
        }
        fmsMaterialUnitMapper.deleteBatchIds(ids);
    }

}

      